package ems;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @Author:石小俊
 * @Date:2022/12/8 15:43
 * @Version:1.0-SNAPSHOT
 * @Description:
 */
@WebServlet("/showAddEmp")
public class ShowAddEmpServlet extends HttpServlet {

    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // 如果响应消息中存在中文,可能会出现中文乱码问题
        // 该乱码称之为响应乱码
        // 可以指定响应对象所使用的编码以及数据的格式
        // response.setContentType("数据格式;charset=字符集")
        response.setContentType("text/html;charset=utf-8");
        PrintWriter out = response.getWriter();
        out.print(" <!DOCTYPE html>  ");
        out.print(" <html lang=\"en\"> ");
        out.print(" <head> ");
        out.print("     <meta charset=\"UTF-8\"> ");
        out.print("     <title>添加员工</title> ");
        out.print(" </head> ");
        out.print(" <body> ");
        out.print(" <h1>添加员工</h1> ");
        out.print(" <a href=\"findAll\">返回员工列表</a> ");
        out.print(" <hr> ");
        // 相对路径
        out.print(" <form action=\"addEmp\" method=\"post\"> ");
//        out.print(" <form action=\"life3\" method=\"post\"> ");
        out.print("     姓名:<input type=\"text\" name=\"name\"><br> ");
        out.print("     工资:<input type=\"text\" name=\"salary\"><br> ");
        out.print("     性别: ");
        out.print("     <input type=\"radio\" value=\"man\" name=\"gender\" checked>男 ");
        out.print("     <input type=\"radio\" value=\"woman\" name=\"gender\">女<br> ");
        out.print("     学历: ");
        out.print("     <select name=\"edu\"> ");
        out.print("         <option value=\"-1\">--请选择--</option> ");
        out.print("         <option value=\"1\">大专</option> ");
        out.print("         <option value=\"2\">本科</option> ");
        out.print("         <option value=\"3\">研究生</option> ");
        out.print("     </select><br> ");
        out.print("     兴趣: ");
        out.print("     <input type=\"checkbox\" name=\"hobbies\" value=\"1\">吃饭 ");
        out.print("     <input type=\"checkbox\" name=\"hobbies\" value=\"2\">睡觉 ");
        out.print("     <input type=\"checkbox\" name=\"hobbies\" value=\"3\">打豆豆<br> ");
        out.print("     <input type=\"submit\" value=\"添加\"> ");
        out.print(" </form> ");
        out.print(" </body> ");
        out.print(" </html> ");
    }

}
